/**
 * 根据当前项目状态来获取下一个可选择的项目状态
 * @param nowBugStatus
 * @returns {[{label: string, value: string}]|[{label: string, value: string}, {label: string, value: string}]}
 */
export function getNextBugStatus(nowBugStatus) {
  let bugStatusOption = ['新建','分配','打开','已解决','关闭','重新打开','拒绝']
  let zeroNext = [{label:'分配',value:'1'}]
  let oneNext = [{label:'打开',value:'2'},{label:'拒绝',value:'6'}]
  let twoNext = [{label:'已解决',value:'3'}]
  let treeNext = [{label:'关闭',value:'4'},{label:'重新打开',value:'5'}]
  let fourNext = [{label:'重新打开',value:'5'}]
  let fiveNext = [{label:'分配',value:'1'}]
  let sixNext = [{label:'关闭',value:'4'},{label:'重新打开',value:'5'}]
  switch (nowBugStatus) {
    case '0':return zeroNext;
    case '1':return oneNext;
    case '2':return twoNext;
    case '3':return treeNext;
    case '4':return fourNext;
    case '5':return fiveNext;
    case '6':return sixNext;
  }
}

export function getNextHandler(nowBugStatus,nextBugStatus) {
  let test = [{ value: '1', label: '项目经理' },{ value: '3', label: '测试工程师' }]
  let development = [{ value: '1', label: '项目经理' },{ value: '2', label: '开发工程师' }]
  if(nowBugStatus === '0' && nextBugStatus === '1' || nowBugStatus === '1' && nextBugStatus === '2' || nowBugStatus === '5' && nextBugStatus === '1'){
    return development;
  }else if(nowBugStatus === '1' && nextBugStatus === '6' || nowBugStatus === '2' && nextBugStatus === '3' || nowBugStatus === '3' && nextBugStatus === '4' || nowBugStatus === '6' && nextBugStatus === '4'){
    return test;
  }else if(nowBugStatus === '3' && nextBugStatus === '5' || nowBugStatus === '4' && nextBugStatus === '5' || nowBugStatus === '6' && nextBugStatus === '5'){
    return [{value: '1', label: '项目经理'}]
  }
}

/**
 * 图表展示将柱状图数据封装成饼图数据
 */
export function histogramToPinChartData(data) {
  // {value: 335, name: '直接访问'}
  let pinChartData = [
    {value: data[0], name: '新建'},
    {value: data[1], name: '分配'},
    {value: data[2], name: '打开'},
    {value: data[3], name: '已解决'},
    {value: data[4], name: '关闭'},
    {value: data[5], name: '重新打开'},
    {value: data[6], name: '拒绝'},
    ]
  return pinChartData;
}
